﻿// dllmain.cpp : 定义 DLL 应用程序的入口点。
#include "pch.h"
#include "DimensionCamera.h"



int main() {

        DimensionCamera *cam = new DimensionCamera();
        cam->InfoFramegrabber("SDK", "info", &cam->_Information, &cam->_ValueList);
        for (auto& dc : cam->getCameraInfoByVendorNameCameraMap()) {
            std::cout << "camera vendor:" << dc.first << std::endl;
            for (auto& hl : dc.second->HandleList) {
                //snap by software
                dc.second->OpenFramegrabberSimgple(&hl, "line0");
                DimensionCamera::DimInfo Image;
                dc.second->GrabImage(hl.Handle,&Image);
                //printf_s("device add %p\n", hl.Handle);
                printf_s("image address %p W:%d H:%d\n", Image.data, Image.width, Image.height);

                //snap by hardware
            }
        }

        //if camera link break for some reason, try to reinitialized it
        delete cam;
        cam = nullptr;
        cam = new DimensionCamera();

        cam->InfoFramegrabber("SDK", "info", &cam->_Information, &cam->_ValueList);
        for (auto& dc : cam->getCameraInfoByVendorNameCameraMap()) {
            std::cout << "camera vendor:" << dc.first << std::endl;
            for (auto& hl : dc.second->HandleList) {
                //snap by software
                dc.second->OpenFramegrabberSimgple(&hl, "line0");
                DimensionCamera::DimInfo Image;
                clock_t clk = clock();
                dc.second->GrabImage(hl.Handle, &Image);
                clock_t cost = clock() - clk;
                //printf_s("device add %p\n", hl.Handle);
                printf_s("snap cost time %zd, image address %p W:%d H:%d\n",cost, Image.data, Image.width, Image.height);

            }
        }

        //free source
        delete cam;
    return 0;
}
